<template>
	<view class="setting-page">
		<u-cell-group>
			<u-cell icon="setting-fill" title="个人设置" :isLink="true" @click="personSetting"></u-cell>
			<u-cell icon="moments-circel-fill" title="小程序" :isLink="true" @click="toInnerHtml"></u-cell>
			<u-cell icon="moments-circel-fill" title="小程序(自定义导航栏)" :isLink="true" @click="toCustomHeaderHtml"></u-cell>
			<u-cell icon="moments-circel-fill" title="微信分享" :isLink="true" @click="uniShare"></u-cell>
			<u-cell icon="moments-circel-fill" title="视频播放" :isLink="true" @click="videoPlayer"></u-cell>
			<u-cell icon="moments-circel-fill" title="renderjs的使用" :isLink="true" @click="testRenderjs"></u-cell>
			<u-cell icon="moments-circel-fill" title="截长图分享" :isLink="true" @click="handleCanvas"></u-cell>
			<u-cell icon="moments-circel-fill" title="滑动切换" :isLink="true" @click="handleswiper"></u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	import UniShare from 'uni_modules/uni-share/js_sdk/uni-share.js';
	const uniShare = new UniShare();

	export default {
		onBackPress({
			from
		}) {
			console.log(from);
			if (from == 'backbutton') {
				this.$nextTick(function() {
					uniShare.hide()
				})
				return uniShare.isShow;
			}
		},
		methods: {
			personSetting() {
				this.$modal.showToast('模块建设中~')
			},
			toInnerHtml() {
				let url = '/static/webview/demo/index.html'
				this.$tab.navigateTo(`/pages/common/webview/index?title=内置web&url=${url}&progress=no`);
			},
			toCustomHeaderHtml() {
				let url = '/static/webview/demo/noheader.html'
				this.$tab.navigateTo(`/pages/common/nohdview/index?title=内置web&url=${url}&progress=no`);
			},
			uniShare() {
				uniShare.show({
					content: { //公共的分享参数配置  类型（type）、链接（herf）、标题（title）、summary（描述）、imageUrl（缩略图）
						type: 0,
						href: 'https://uniapp.dcloud.io/',
						title: '标题',
						summary: '描述',
						imageUrl: 'https://img-cdn-aliyun.dcloud.net.cn/stream/icon/__UNI__HelloUniApp.png'
					},
					menus: [{
							"img": "/static/app-plus/sharemenu/wechatfriend.png",
							"text": "微信好友",
							"share": { //当前项的分享参数配置。可覆盖公共的配置如下：分享到微信小程序，配置了type=5
								"provider": "weixin",
								"scene": "WXSceneSession"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/wechatmoments.png",
							"text": "微信朋友圈",
							"share": {
								"provider": "weixin",
								"scene": "WXSceneTimeline"
							}
						},
						// {
						// 	"img": "/static/app-plus/sharemenu/mp_weixin.png",
						// 	"text": "微信小程序",
						// 	"share": {
						// 		provider: "weixin",
						// 		scene: "WXSceneSession",
						// 		type: 5,
						// 		miniProgram: {
						// 			id: '123',
						// 			path: '/pages/list/detail',
						// 			webUrl: '/#/pages/list/detail',
						// 			type: 0
						// 		},
						// 	}
						// },
						{
							"img": "/static/app-plus/sharemenu/weibo.png",
							"text": "微博",
							"share": {
								"provider": "sinaweibo"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/qq.png",
							"text": "QQ",
							"share": {
								"provider": "qq"
							}
						},
						{
							"img": "/static/app-plus/sharemenu/copyurl.png",
							"text": "复制",
							"share": "copyurl"
						},
						{
							"img": "/static/app-plus/sharemenu/more.png",
							"text": "更多",
							"share": "shareSystem"
						}
					],
					cancelText: "取消分享",
				}, e => { //callback
					console.log(uniShare.isShow);
					console.log(e);
				})
			},
			videoPlayer(){
				this.$tab.navigateTo(`/pages/video/video`);
			},
			testRenderjs(){
				this.$tab.navigateTo(`/pages/test-renderjs/test-renderjs`);
			},
			handleCanvas(){
				this.$tab.navigateTo(`/pages/html2canvas/html2canvas`);
			},
			handleswiper(){
				this.$tab.navigateTo(`/pages/swiper-tabbar/swiper-tabbar`);
			}
		},
        onLoad() {
        	const MyTest = uni.requireNativePlugin("mylibrary-debug"); // PluginName 为原生插件名称
			console.log('调用插件',MyTest.getTestData())
			
			let {test_data} = MyTest.getTestData();
			uni.showToast({
				title: test_data,
				icon: 'none',
				duration: 3000
			});
        }

	}
</script>

<style lang="scss" scoped>
	.setting-page {
		width: 100%;
		height: calc(100vh);
		overflow-y: scroll;
		background: #FFF;
	}

	.u-slot-value {
		color: blue;
	}
</style>